<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>检验</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/scan/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/scan/css/default.css"/>
    <script src="/scan/js/jquery.min.js"></script>
    <script src="/scan/js/bootstrap.min.js"></script>
</head>
<body>
<header class="head">
    <span class="step-back">
        <a onclick="javascript:window.history.back(-1);"  role="button" style="color: #808080" class="glyphicon glyphicon-chevron-left"></a>
    </span>
    <span style="padding-right: 5px">随货同行单检验</span>
</header>
<div class="container-fluid">
    <form onsubmit="return false;">
        <div class="form-group" style="text-align: left">
            <label for="TXM">条形码:</label>
            <input type="text" class="form-control" placeholder="" id="TXM" autocomplete="off">
        </div>
    </form>
    <div class="table-responsive">
        <table class="table table-condensed">
            <thead>
            <tr>
                <th>序号</th>
                <th>单据编号</th>
                <th>交单</th>
                <th>是否一致</th>
            </tr>
            </thead>
            <tbody id="showData">

            </tbody>
        </table>
    </div>
</div>

<div class="modal fade"  id="loadingModal" data-backdrop="static">
    <div style="width: 200px;height:20px; z-index: 20000; position: absolute; text-align: center; left: 50%; top: 50%;margin-left:-100px;margin-top:-10px">
        <div class="progress progress-striped active" style="margin-bottom: 0;">
            <div class="progress-bar" style="width: 100%;"></div>
        </div>
        <h5 style="color:black"> <strong>loading...</strong> </h5>
    </div>
</div>
</body>
<script>
    $("#TXM").focus();
    var txm="";
    var jybs="";
    var data_index=1;
    $(document).off("keypress").on("keypress","#TXM",function(e){
        if(e.keyCode == 13)
        {
            txm=$("#TXM").val();
            jybs=$("#TXM").val();
            if(txm==""||txm==undefined){
                return false;
            }
            $("#loadingModal").modal('show');
            $("#TXM").blur();
            var index=txm.length;
            var f=txm.indexOf("#*");
            if(f>-1) {
                index = f;
            }
            var o=txm.substring(0,index);
            console.log(o);
            $.ajax({
                type: 'POST',
                url: '/scan/shtxdjy',
                data: {txm:o,jybs:jybs},
                dataType:"JSON",
                success: function (data) {
                    console.log(data);
                    if(data.code==0){
                        var re=data.data;
                        var html="<tr>"+
                            "<td class='hg-xh'>"+data_index+"</td>" +
                            "<td class='hg-bh'>"+txm+"</td>" +
                            "<td class='hg-jd'>"+re.F_HG_JD+"</td>" +
                            "<td class='hg-yz'>"+re.F_HG_SFYZ+"</td>" +
                            "</tr>";
                        $("#showData").append(html);
                        data_index++;
                        $("#TXM").val("");
                        $("#TXM").focus();
                    }else{
                        if(data.code!=99) {
                            alert(data.msg);
                        }else{
                            var html="<tr>"+
                                "<td class='hg-xh'>"+data_index+"</td>" +
                                "<td class='hg-bh'>"+txm+"</td>" +
                                "<td class='hg-jd'>该单已被检验</td>" +
                                "<td class='hg-yz'>该单已被检验</td>" +
                                "</tr>";
                            $("#showData").append(html);
                            data_index++;
                            $("#TXM").val("");
                            $("#TXM").focus();
                        }
                    }
                    $("#loadingModal").modal('hide');
                },
                error:function () {
                    alert("服务器出错，请稍后再试");
                    $("#loadingModal").modal('hide');
                }
            });
        }
    });
</script>
</html>